package com.boboPlanet.user.fallback;

import com.boboPlanet.comm.enums.FeignErrorEnum;
import com.boboPlanet.comm.result.ResponseResult;
import com.boboPlanet.user.entity.dto.SysLogDTO;
import com.boboPlanet.user.entity.po.SysLogPO;
import com.boboPlanet.user.feignApi.SysLogApi;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/2/25
 **/
@Slf4j
@Component
public class SysLogFallbackImpl implements FallbackFactory<SysLogApi> {
    @Override
    public SysLogApi create(Throwable cause) {
        return new SysLogApi() {
            @Override
            public ResponseResult<Boolean> addSysLog(SysLogDTO dto) {
                log.error("fallback method is: {} ,param is: {} , exception is: {}, errMsg is: {}","addSysLog",dto,cause,cause.getMessage());
                return ResponseResult.error(FeignErrorEnum.FEIGN_ADD_LOG_ERROR,null);
            }

            @Override
            public ResponseResult<List<SysLogPO>> querySysLog(SysLogDTO dto) {
                log.error("fallback method is: {} ,param is: {} , exception is: {}, errMsg is: {}","querySysLog",dto,cause,cause.getMessage());
                return ResponseResult.error(FeignErrorEnum.FEIGN_GET_LOG_ERROR,null);
            }
        };
    }
}
